<?php
if ( !defined( "IN_OP" ) )
{
    exit( "You can't access this file directly..." );
}
$lotto_id = intval( $_GET['id'] );
$conf = new Config();
$stopbet = $conf->get( "waitbet" );
if ( !isset( $_SESSION['saywaitmod2'] ) )
{
    $_SESSION['saywaitmod2'] = 0;
}
$saystopmod = $_SESSION['saywaitmod2'];
if ( $stopbet <= date( "Hi" ) && !$saystopmod )
{
    $saystopmod = 1;
    $_SESSION['saywaitmod2'] = $saystopmod;
    echo "-1";
    exit();
}
$disk_code = "a";
$diskStr = "";
$split = 1;
$ratemod = 1;
include( "class_6h/BetTotal_6h.php" );
$BetTotal_6h = new BetTotal_6h( $lotto_id );
$colors = array( "", "red", "blue", "green" );
$dataTotalArr = array();
$showDataArr = array();
$total_win = array( 1006 => 0, 1007 => 0 );
$theacl = $curruser['acl'];
$userid = $curruser['id'];
$showid = $theacl == 255 ? "0" : $userid;
$bettypeStr = "1006,1007";
$i = 1;
while ( $i < 13 )
{
    $showDataArr[1006][$i] = array( "numbers" => $i, "totalnum" => 0, "amount" => 0, "amount_rate" => 0, "rate" => 0, "back1" => 0, "back2" => 0, "winlost" => 0, "namount" => "" );
    ++$i;
}
$i = 1;
while ( $i < 11 )
{
    $showDataArr[1007][$i] = array( "numbers" => $i, "totalnum" => 0, "amount" => 0, "amount_rate" => 0, "rate" => 0, "back1" => 0, "back2" => 0, "winlost" => 0, "namount" => "" );
    ++$i;
}
$dataTotalArr[1006] = array( "bettype" => 1006, "totalnum" => 0, "amount" => 0, "amount_rate" => 0, "back1" => 0, "back2" => 0 );
$dataTotalArr[1007] = array( "bettype" => 1007, "totalnum" => 0, "amount" => 0, "amount_rate" => 0, "back1" => 0, "back2" => 0 );
$totalRs = $BetTotal_6h->getDataListTotal( $lotto_id, $bettypeStr, $showid, $split, $diskStr );
while ( !$totalRs->eof )
{
    $tempIdx = $totalRs->f['bettype'];
    $dataTotalArr[$tempIdx] = $totalRs->f;
    $totalRs->next();
}
$totalRs->close();
if ( isset( $dataTotalArr[1006] ) )
{
    $total_win[1006] = $dataTotalArr[1006]['amount'] - $dataTotalArr[1006]['back1'] + $dataTotalArr[1006]['back2'];
}
if ( isset( $dataTotalArr[1007] ) )
{
    $total_win[1007] = $dataTotalArr[1007]['amount'] - $dataTotalArr[1007]['back1'] + $dataTotalArr[1007]['back2'];
}
$sql = $BetTotal_6h->getDataListByNumSsSQL( $lotto_id, $bettypeStr, $showid, $diskStr, $split, $ratemod );
$rs = getdb( $sql );
$updatetime = systime( ) - 30;
while ( !$rs->eof )
{
    $bettype = $rs->f['bettype'];
    $i = $rs->f['numbers'];
    $showDataArr[$bettype][$i]['totalnum'] = $rs->f['totalnum'];
    $showDataArr[$bettype][$i]['amount'] = $rs->f['amount'];
    $showDataArr[$bettype][$i]['amount_rate'] = $rs->f['amount_rate'];
    $showDataArr[$bettype][$i]['rate'] = $rs->f['rate'];
    $rs->next();
}
$rs->close();
$rs = getdb( "select * from rate1{$disk_code} where lotto_id={$lotto_id}" );
$i = 1;
while ( $i < 13 )
{
    $showDataArr[1006][$i]['rate'] = $rs->f["r21_{$i}"] - 0;
    ++$i;
}
$i = 1;
while ( $i < 11 )
{
    $showDataArr[1007][$i]['rate'] = $rs->f["r22_{$i}"] - 0;
    ++$i;
}
$rs->close();
echo $total_win[1006];
$i = 1;
while ( $i < 13 )
{
    echo ",".$showDataArr[1006][$i]['rate']."@".$showDataArr[1006][$i]['totalnum']."@".$showDataArr[1006][$i]['amount'];
    echo "@".$showDataArr[1006][$i]['amount_rate'];
    ++$i;
}
echo "\n";
echo $total_win[1007];
$i = 1;
while ( $i < 11 )
{
    echo ",".$showDataArr[1007][$i]['rate']."@".$showDataArr[1007][$i]['totalnum']."@".$showDataArr[1007][$i]['amount'];
    echo "@".$showDataArr[1007][$i]['amount_rate'];
    ++$i;
}
echo "\n";
include( "class_6h/class.menu.php" );
$fieldArr = array( "lotto_id" => $lotto_id, "split_id" => 1 );
$onlineMenu = new menu_6h( 2, $fieldArr );
echo $onlineMenu->getMenuAmu();
echo "\n";
exit();
?>